﻿using System;

namespace Normalify
{
    public class Statistics
    {
		public int Zeros { get; set; }
        public double Min { get; set; }
        public double Max { get; set; }
        public double Sum { get; set; }
        public double Mean { get; set; }
        public int Count { get; set; }
        public double M2 { get; set; }
        public double M3 { get; set; }
        public double M4 { get; set; }

        public Statistics()
        {
            Count = 0;
            Min = int.MaxValue;
            Max = int.MinValue;
            Sum = 0;
        }

        public double GetVariance()
        {
	        if (Count < 3) return 0;
            return M2/(Count - 1);
        }

        public double GetSkewness()
        {
	        if (M2 < 0.0001) return 0;
            return Math.Sqrt(Count/(M2*M2*M2))*M3;
        }

        /// <summary>
        /// High Kurtosis (above 1) means a peaky shape.
        /// Kurtosis under -1 means a relatively flat shape.
        /// Kurtosis equal to 0 is normal distribution
        /// </summary>
        /// <returns></returns>
        public double GetKurtosis()
        {
	        if (M2 < 0.0001) return 0;
            return (Count*M4)/(M2*M2) - 3;
        }
    }
}